const Koa = require('koa');
const koaEjs = require('koa-ejs');
const pathLib = require('path');
const koaStaticCache = require('koa-static-cache');

let server = new Koa();

koaEjs(server, {
    root: pathLib.resolve(__dirname, './view'),
    layout: false,
    viewExt: 'ejs',
    cache: false,
    debug: false
});

require('./router')(server);

server.use(koaStaticCache(pathLib.resolve(__dirname, './static'), {
    prefix: '/public',
    maxAge: 86400 * 1000,
    gzip: true
}));

server.listen(8080, () => {
    console.log('server running at 8080 port');
}); 